home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 5: The Fifth Dimension
/
17 Bit - The Fifth Dimension (1995)(17 Bit Software)[!].iso
/
files
/
3556.dms
/
3556.adf
/
CalenderMacros
/
calendar.fw2
next >
Wrap
Text File
|
1995-01-31
|
12KB
|
344 lines
/* Calendar macro for FinalWriter (SoftWood)
Written by Andrew McCardie
amethyst@gulf.net
November 29th, 1994
$VER: FW Calendar Macro v1.1 for FW2.x
This macro works only under FinalWriter version 2.x. FW3
is supported in the other macro in this archive.
This macro can create three different types of calendars: Portrait,
double-portrait, and landscape. It supports all years that are
supported by the Amiga's internal calendar (1978 ->)
Portrait produces a standard 8.5x11 page with a single calendar.
Double portrait produces a standard 8.5x11 page with two calendars.
Landscape produces a standard 11x8.5 page with a single calendar.
While it should handle leap-years, this feature has not been
exhaustively tested. The fonts and margins are designed to be
user-customizeable. Certain default values (in inches) have been
hardcoded into the variables 'top_margin', 'bottom_margin', and
'side_margin' to produce the largest calendars on my DeskJet. You
can change these if you need a smaller calendar or if the calendars
print incorrectly on your setup.
If you change the default fonts, you may have to experiment with their
sizes and widths to get an appropriate look.
If you find any bugs, let me know and I'll try to rectify them.
Disclaimer: I take no responsibility for problems that may result from using
this macro.
*/
OPTIONS RESULTS
ADDRESS "FINALW.1"
ClearDoc FORCE
View 25 /* Speeds things up slightly on fast machines, probably more on
slower machines.
*/
SetMeasure MicroPoints
BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
TextBlockPrefs TEXTFLOW None
micropoints_per_inch = 720
ShowMessage 1 0 '"What type of calendar?" "" "" "Portrait" "Double-Portrait" "Landscape"'
calendar_type = RESULT
Select
/* Portrait calendar */
When calendar_type = 1 Then
Do
PageSetup PAGETYPE USLetter ORIENT Tall
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
boxwidth = Trunc(pagewidth/7)
boxheight = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Dragon_BoldItalic"
datestring_font_size = 64
datestring_font_width = 100
text_font = "Dragon_BoldItalic"
text_font_size = 20
text_font_width = 80
day_font = "Dragon_Bold"
day_font_size = 20
day_font_width = 100
iteration = 1
End
/* Double-portrait calendar */
When calendar_type == 2 Then
Do
PageSetup PAGETYPE USLetter ORIENT Tall
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(5.50 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
boxwidth = Trunc(pagewidth/7)
boxheight = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Dragon_BoldItalic"
datestring_font_size = 34
datestring_font_width = 150
text_font = "Dragon_BoldItalic"
text_font_size = 20
text_font_width = 80
day_font = "Dragon_Bold"
day_font_size = 20
day_font_width = 100
iteration = 2
End
/* Landscape calendar */
When calendar_type == 3 Then
Do
PageSetup PAGETYPE USLetter ORIENT Wide
GetPageSetup WIDTH HEIGHT
Parse Var RESULT true_width true_height
/* The following measurements are based on inches converted to micropoints
Experiment with the defaults at your own risk, however. :) */
side_margin = Trunc(.5 * micropoints_per_inch)
top_margin = Trunc(.625 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
boxwidth = Trunc(pagewidth/7)
boxheight = Trunc((pageheight-text_area)/5)
bevel_control = "BEVEL"
SectionSetup TOP top_margin INSIDE side_margin OUTSIDE side_margin
/* Set up font defaults */
datestring_font = "Montreal_BoldItalic"
datestring_font_size = 44
datestring_font_width = 150
text_font = "Montreal_BoldItalic"
text_font_size = 22
text_font_width = 80
day_font = "Montreal_Bold"
day_font_size = 20
day_font_width = 100
iteration = 1
End
End
current_month = -1
current_month_number = -1
current_year = -1
temp_date = "00000000"
day.0 = 'Saturday'
day.1 = 'Sunday'
day.2 = 'Monday'
day.3 = 'Tuesday'
day.4 = 'Wednesday'
day.5 = 'Thursday'
day.6 = 'Friday'
month.0 = 'January'
month.1 = 'February'
month.2 = 'March'
month.3 = 'April'
month.4 = 'May'
month.5 = 'June'
month.6 = 'July'
month.7 = 'August'
month.8 = 'September'
month.9 = 'October'
month.10 = 'November'
month.11 = 'December'
month_length.0 = 31
month_length.1 = 28
month_length.2 = 31
month_length.3 = 30
month_length.4 = 31
month_length.5 = 30
month_length.6 = 31
month_length.7 = 31
month_length.8 = 30
month_length.9 = 31
month_length.10 = 30
month_length.11 = 31
RequestText '"Month Select" "Month:" 'DATE('M')''
current_month = RESULT
RequestText '"Year Select" "Year:" 'SUBSTR(DATE('S'),1,4)''
current_year = RESULT
if current_year < 1978 then current_year = 1978
Do i = 0 to 11
If current_month = month.i Then current_month_number = i + 1
End
Do While iteration > 0
If current_year//4 == 0 & current_year//100 > 0 Then
month_length.1 = 29
Else
If current_year//400 == 0 Then
month_length.1 = 29
Select
When current_month_number < 10 Then
temp_date = current_year || 0 || current_month_number || "01"
When current_month_number >= 10 Then
temp_date = current_year || current_month_number || "01"
When current_month_number == -1 Then
Exit 10
End
first_day_of_the_month = Date('W', temp_date, 'S')
Select
When first_day_of_the_month == "Saturday" Then cal_start = 0
When first_day_of_the_month == "Sunday" Then cal_start = 1
When first_day_of_the_month == "Monday" Then cal_start = 2
When first_day_of_the_month == "Tuesday" Then cal_start = 3
When first_day_of_the_month == "Wednesday" Then cal_start = 4
When first_day_of_the_month == "Thursday" Then cal_start = 5
When first_day_of_the_month == "Friday" Then cal_start = 6
End
/* Create month/year header */
TextBlockTypePrefs SIZE datestring_font_size WIDTH datestring_font_width FONT datestring_font
datestring = current_month || " " || current_year
DrawTextBlock 1 side_margin top_margin datestring
datestring_obj = RESULT
GetObjectCoords datestring_obj
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
text_edge = Trunc(side_margin + (pagewidth - obj_width)/2)
SetObjectCoords datestring_obj Page text_edge obj_top obj_width obj_height
i = 0
Do While (i < 7)
j = 0
box_left = side_margin+boxwidth*i
box_top = top_margin+text_area
TextBlockTypePrefs SIZE text_font_size WIDTH text_font_width FONT text_font
DrawTextBlock 1 box_left box_top-text_font_size*11 day.i
text_obj.i = RESULT
GetObjectCoords text_obj.i
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
text_edge = Trunc(box_left + (boxwidth - obj_width)/2)
SetObjectCoords text_obj.i Page text_edge obj_top obj_width obj_height
Do While (j < 5)
serial_position = i + (j * 7)
index = current_month_number - 1
If serial_position >= cal_start & serial_position < cal_start+month_length.index
Then BoxPrefs LINEWT 2 LINECOLOR Black FILL Transparent TEXTFLOW None
Else BoxPrefs LINEWT 2 LINECOLOR Black FILL Solid FILLCOLOR Cyan TEXTFLOW None
box_top = top_margin+text_area+boxheight*j
DrawBox 1 box_left box_top boxwidth boxheight bevel_control
box_obj.i.j = RESULT
day_of_month = serial_position-cal_start+1
TextBlockTypePrefs SIZE day_font_size WIDTH day_font_width FONT day_font
GetBoxPrefs FILL
If RESULT = "Transparent" Then
If day_of_month < 10 Then
DrawTextBlock 1 box_left+boxwidth-200 box_top+boxheight-200 day_of_month
Else
DrawTextBlock 1 box_left+boxwidth-300 box_top+boxheight-200 day_of_month
Else NOP
j = j + 1
End
i = i + 1
End
/* Special cases for months whose last day(s) wrap to the
beginning of the week */
If cal_start+month_length.index == 36 Then
Do
day_of_month = day_of_month + 1
GetObjectCoords box_obj.0.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+50 day_of_month
End
If cal_start+month_length.index == 37 Then
Do
day_of_month = day_of_month + 1
GetObjectCoords box_obj.0.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+50 day_of_month
day_of_month = day_of_month + 1
GetObjectCoords box_obj.1.4
coords = RESULT
Parse Var coords Page obj_left obj_top obj_width obj_height
DrawLine Page obj_left+40 obj_top+obj_height-40 obj_left+obj_width-40 obj_top+40
DrawTextBlock 1 obj_left+50 obj_top+50 day_of_month
End
/* Handles special case of double portrait calendar */
If iteration == 2 Then
Do
drop datestring
top_margin = Trunc(5.5 * micropoints_per_inch)
bottom_margin = Trunc(.625 * micropoints_per_inch)
pagewidth = Trunc(true_width - 2 * side_margin)
pageheight = Trunc(true_height - top_margin - bottom_margin)
text_area = Trunc(.15 * pageheight) /* 15% of calendar size devoted to titles */
boxwidth = Trunc(pagewidth/7)
boxheight = Trunc((pageheight-text_area)/5)
If current_month_number < 12 Then
Do
current_month = month.current_month_number
current_month_number = current_month_number + 1
End
Else
Do
current_month_number = 1
current_month = "January"
current_year = current_year + 1
End
End
iteration = iteration - 1
End
SectionSetup BOTTOM bottom_margin
SelectObject
Redraw
View 50